package com.aegean.MonitorExamSYS.tool.business.impl;

import java.util.Date;
import java.util.List;
import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aegean.MonitorExamSYS.examinee.dao.ExamineeDao;
import com.aegean.MonitorExamSYS.monitor.business.MonitorBusiness;
import com.aegean.MonitorExamSYS.monitor.dao.MonitorDao;
import com.aegean.MonitorExamSYS.tool.business.ToolBusiness;
import com.aegean.MonitorExamSYS.tool.dao.ToolDao;
import com.aegean.MonitorExaxSYS.model.BigType;
import com.aegean.MonitorExaxSYS.model.ConductionValue;
import com.aegean.MonitorExaxSYS.model.ExamInfo;
import com.aegean.MonitorExaxSYS.model.ExamineeValue;
import com.aegean.MonitorExaxSYS.model.MonitorValue;
import com.aegean.MonitorExaxSYS.model.SmallType;

@Service
@Transactional
public class ToolBusinessImpl implements ToolBusiness {
	@Resource
	ToolDao dao;

	@Override
	public int searchBigTypeCount() {
		return dao.searchBigTypeCount();
	}

	@Override
	public List<BigType> searchPartBigTypes(int start, int limit) {
		return dao.searchPartBigTypes(start, limit);
	}

	@Override
	public int searchSmallTypeCount(int big_Id) {
		// TODO Auto-generated method stub
		return dao.searchSmallTypeCount(big_Id);
	}

	@Override
	public List<SmallType> searchPartSmallTypes(int big_Id, int start, int limit) {
		// TODO Auto-generated method stub
		return dao.searchPartSmallTypes(big_Id, start, limit);
	}

	@Override
	public ExamInfo searchExamInfo(int exam_Id) {
		// TODO Auto-generated method stub
		return dao.searchExamInfo(exam_Id);
	}

	@Override
	public List<ExamInfo> showExamList(String key, int small_Id,
			int exam_status, int start, int limiit, String exam_Name,
			Date startTime, Date endTime, int status) {
		// TODO Auto-generated method stub
		switch (status) {
		case 1:// 查询最新考试动态列显最多8个
			DetachedCriteria dr = DetachedCriteria.forClass(ExamInfo.class);
			dr.addOrder(Order.desc("examInfo_CreateTime"));
			dr.add(Restrictions.eq("examInfo_State", exam_status));
			return dao.showExamList(key, small_Id, exam_status, start, limiit,
					exam_Name, startTime, endTime, status, dr);
		case 2:
			return dao.showExamList(key, small_Id, exam_status, start, limiit,
					exam_Name, startTime, endTime, status, null);
		case 3:
			break;
		case 4:
			break;
		default:
			break;
		}
		return null;
	}

	@Override
	public int countExamList(String key, int small_Id, int exam_status,
			int start, int limiit, String exam_Name, Date startTime,
			Date endTime, int status) {
		// TODO Auto-generated method stub
		switch (status) {
		case 1:// 查询最新考试动态列显最多8个
			DetachedCriteria dr = DetachedCriteria.forClass(ExamInfo.class);
			dr.addOrder(Order.desc("examInfo_CreateTime"));
			dr.add(Restrictions.eq("examInfo_State", exam_status));
			return dao.countExamList(key, small_Id, exam_status, start, limiit,
					exam_Name, startTime, endTime, status, dr);
		case 2:
			return dao.countExamList(key, small_Id, exam_status, start, limiit,
					exam_Name, startTime, endTime, status, null);
		case 3:
			break;
		case 4:
			break;
		default:
			break;
		}
		return 0;
	}
}
